package com.vhly.ddxdecompiler.dexreader.file.mixeditem;

import com.vhly.ddxdecompiler.dexreader.file.DexFile;
import com.vhly.ddxdecompiler.dexreader.file.TypeIdsSection;
import com.vhly.ddxdecompiler.dexreader.io.DexInputStream;

import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Vector;

/**
 * Created by IntelliJ IDEA.
 * User: vhly
 * Date: 2009-10-15
 * Time: 12:48:22
 *
 * @author vhly[FR]
 */
public final class TypeListItem extends OffsettedItem {

    short[] typeListIndex;
    /**
     * 参数列表
     */
    Vector<TypeIdItem> items;

    private DexFile dex;

    public TypeListItem(DexFile dexFile) {
        super(4, 0);
        dex = dexFile;
        items = new Vector<TypeIdItem>();
    }

    /**
     * 读取数据
     *
     * @param din 输入流
     * @throws java.io.IOException 异常
     */
    public void read(DexInputStream din) throws IOException {
        int sz = din.readInt();
        if (sz > 0) {
            typeListIndex = new short[sz];
            short index;
            TypeIdsSection typeIds = dex.getTypeIds();
            for (int i = 0; i < sz; i++) {
                index = din.readShort();
                typeListIndex[i] = index;
                TypeIdItem idItem = typeIds.indexOf(index);
                items.add(idItem);
            }
        }
    }

    /**
     * 输出数据
     *
     * @param dout 输出流
     * @throws java.io.IOException 异常
     */
    public void write(DataOutputStream dout) throws IOException {
    }
}
